#!/bin/bash
#
# Frequency:
# ~15 minutes data is appended to the file (offset download by 3 min)
#
# Files:
# out.gz is the data
# tbl.gz is the station catalog

project_build="/cygdrive/c/data/dropbox/cmpe275/project1/climspace/build"
jboss_home="/cygdrive/c/jboss6"
hadoop_home="/home/dnguyen/hadoop-0.20.2"
mesowest_home="/home/dnguyen/mesowest/download"
run_ts=`date +%Y%m%d_%H%M`
outFile="mesowest_$run_ts.out"
csvFile="mesowest_csv_$run_ts.tbl"

wget --directory-prefix=$mesowest_home/ -N --no-cache \
     http://mesowest.utah.edu/data/mesowest.out.gz \
     http://mesowest.utah.edu/data/mesowest_csv.tbl.gz\

gunzip $mesowest_home/*.gz

mv $mesowest_home/mesowest.out $mesowest_home/$outFile
mv $mesowest_home/mesowest_csv.tbl $mesowest_home/$csvFile

#java CAPAPortalClient "filename"
#java CAPAPortalClient "filename"


runcp="$jboss_home/client/jbossall-client.jar:$project_build/climspace_client.jar"

#cygwin version
runjava="java -cp `cygpath -wp $runcp` climspace.client.CAPAPortalClient `cygpath -w $mesowest_home/$csvFile` `cygpath -w $mesowest_home/$outFile`"

#unix version
#runjava="java -cp $runcp climspace.client.CAPAPortalClient $mesowest_home $mesowest_home/$outFile"

echo $runjava
$runjava
